/*
 * =====================================================================================
 * Copyright (C) 2023 Ingenic Semiconductor Co.,Ltd
 * All Rights Reserved
 *
 * Filename     : i2c.h
 * Author       : Keven <keven.ywhan@ingenic.com>
 * Created      : 2024/06/25 10:40
 * Description  :
 *
 * =====================================================================================
 */

#ifndef __I2C_H__
#define __I2C_H__
struct i2c_config {
	uint8_t adapter;
	uint32_t dma_buf_addr;
	uint32_t dma_buf_size;
};

struct i2c_msg {
	uint8_t adapter;
	uint16_t addr;	/*slave address*/
	uint32_t flags;
#define I2C_PIO_MODE            (0x0001)
#define I2C_DMA_MODE            (0x0002)
#define I2C_ADDR_10BIT          (0x0010)
	uint32_t buf_data_format;
#define REG_8BIT_VALUE_8BIT     (0x0)
#define REG_16BIT_VALUE_8BIT    (0x1)
#define REG_8BIT_VALUE_16BIT    (0x2)
#define REG_16BIT_VALUE_16BIT   (0x3)
	uint32_t len;
	void *buf;

	void (*callback)(void *cb_data);
	void *cb_data;
};

int32_t i2c_init(struct i2c_config *config);
int32_t i2c_write(struct i2c_msg *msg);
int32_t i2c_read(struct i2c_msg *msg);

#endif /* __I2C_H__ */

